package com.junjie.food.orderServiceManager.controller;

import com.junjie.food.orderServiceManager.vo.OrderCreateVo;
import com.junjie.food.orderServiceManager.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/orders")
    public void createOrder(@RequestBody OrderCreateVo orderCreateVo) throws Exception{
        // 这里打印日志不该用 + 拼接
        // 因为如果系统日志级别是DeBug 那么info不该出现
        // 但是这里拼接字符串就会导致多判断一次是否应该出现，因此建议使用{}
        log.info("createOrderVo:{}",orderCreateVo);
        orderService.createOrder(orderCreateVo);
    }
}
